﻿using System;
using System.Windows.Forms;

namespace StickTops
{
    public partial class RegisterForm : Form
    {
        public RegisterForm()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == "")
            {
                MessageBox.Show("Please enter a username");
                return;
            }

            if (textBox2.Text == "")
            {
                MessageBox.Show("Please Enter a password");
                return;
            }

            SaveSql save = new SaveSql();
            save.CreateUser(textBox1.Text, textBox2.Text);

            if (save.State == SaveSql.LogInState.UserExists)
            {
                MessageBox.Show("The username is taken");
                return;
            }

            if (save.State == SaveSql.LogInState.ConnError)
            {
                MessageBox.Show("Check your internet connection");
            }

            if (save.State == SaveSql.LogInState.Success)
            {
                MessageBox.Show("User Created!");
                this.Close();
            }
            else MessageBox.Show(save.Message);


        }

    }
}
